package ch.yiyangerp.action.login;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import ch.yiyangerp.action.IAction;
import ch.yiyangerp.service.login.UserLoginService;

/**
 * 
 * @author grc
 * @date 2015-12-13 18:30:37
 */
public class LoginAction extends ActionSupport implements IAction{

	// Spring 依赖注入
	private UserLoginService userLoginService;
	
	public String login()
	{

		if(userLoginService.loginSearch(getUserName(), getUserPassword()))
		{
			// session 里设置userName 和 userPassword
			ActionContext.getContext().getSession().put("userName", getUserName());
//			ActionContext.getContext().getSession().put("userPassword", getUserPassword());
			return IAction.SUCCESS;
		}
		else
		{
			ActionContext.getContext().getSession().put("userName", getUserName());
			return IAction.ERROR;
		}
		
	}
	


	private String userName;
	private String userPassword;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}
	
	public UserLoginService getUserLoginService() {
		return userLoginService;
	}

	public void setUserLoginService(UserLoginService userLoginService) {
		this.userLoginService = userLoginService;
	}

}
